#include "utils.h"

void Kfree(const void *p) {
    if (p == NULL) {
        pr_alert("free NULL pointer");
    } else {
        kfree(p);
    }
}

void *Kzalloc(size_t size) {
    void *ret = kzalloc(size, GFP_KERNEL);
    if (ret == NULL) {
        printk("kzalloc return NULL\n");
        // ERRHDL
    }
    return ret;
}

void hash_entry_free(void *ptr, void *arg)
{
    Kfree(ptr);
}

void dumpArray(char arr[], int size) {
    int i;
    for (i = 0; i < size; i+=4) {
        pr_alert("%02X%02X%02X%02X", arr[i], arr[i+1], arr[i+2], arr[i+3]);
    }
}

int *DBG_VALID_LIST;
void init_DBG(void) {
    DBG_VALID_LIST = Kzalloc(100 * sizeof(int));
    DBG_VALID_LIST[DBG_READ_DEDUP] = 0;
    DBG_VALID_LIST[DBG_WRITE_DEDUP] = 0;
    DBG_VALID_LIST[DBG_LRU_LIST] = 0;
}